﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MantenimientoDeComercios.aspx.cs" Inherits="Web_Guia_Digital_Georeferenciada.Mantenimientos.MantenimientoDeComercios" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel = "Stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<link rel="stylesheet" href="../Content/bootstrap.min.css" type="text/css" /> 
<link rel="stylesheet" href="../Content/bootstrap-theme.min.css" type="text/css" /> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>


         
<script type="text/javascript">
    var contador = 1;
    var nombreTags = "tag";
    var infowindow; var marcadores = [];
    var geocoder; var marker; var latLng; var latLng2;
    var map;

    // INICiALIZACION DE MAPA
    function initialize() {
        geocoder = new google.maps.Geocoder();
        latLng = new google.maps.LatLng(-34.90, -56.130);
        map = new google.maps.Map(document.getElementById('map-canvas'), {
            zoom: 14,
            center: latLng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        });


        // CREACION DEL MARCADOR  
        marker = new google.maps.Marker({
            position: latLng,
            title: 'Arrastra el marcador para buscar comercios cerca',
            map: map,
            draggable: true
        });
        // Escucho el CLICK sobre el mapa y si se produce actualizo la posicion del marcador 
        google.maps.event.addListener(map, 'click', function (event) {
            updateMarker(event.latLng);
        });
        // Inicializo los datos del marcador
        geocodePosition(latLng);


        google.maps.event.addListener(marker, 'dragend', function () {
            updateMarker(marker.getPosition());
        });
    }


    // Permito la gesti¢n de los eventos DOM
    google.maps.event.addDomListener(window, 'load', initialize);



    // RECUPERO LOS DATOS LON LAT Y DIRECCION Y LOS PONGO EN EL FORMULARIO
    function updateMarkerPosition(latLng) {
        geocodePosition(latLng);
        $('#txtLongitud').val(latLng.lng() + ";" + latLng.lat());
    }


    // ACTUALIZO LA POSICION DEL MARCADOR
    function updateMarker(location) {
        marker.setPosition(location);
        updateMarkerPosition(location);
    }
    function updateMarkerAddress(str) {

        $('#txtDireccion').val(str);
    }
    // ESTA FUNCION OBTIENE LA DIRECCION A PARTIR DE LAS COORDENADAS POS
    function geocodePosition(pos) {
        geocoder.geocode({
            latLng: pos
        }, function (responses) {
            if (responses && responses.length > 0) {
                updateMarkerAddress(responses[0].formatted_address);
            } else {
                updateMarkerAddress('No puedo encontrar esta direccion.');
            }
        });
    }


    /*

    */
    $(document).ready(function () {
        $("#<%=txtBuscarSucursales.ClientID %>").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: '<%=ResolveUrl("~/Mantenimientos/ServiciosAutocompletado.asmx/GetCustomers") %>',
                    data: "{ 'prefix': '" + request.term + "'}",
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        response($.map(data.d, function (item) {
                            return {
                                label: item.split('-')[0],
                                val: item.split('-')[1]
                            }
                        }))
                    },
                    error: function (response) {
                        alert(response.responseText);
                    },
                    failure: function (response) {
                        alert(response.responseText);
                    }
                });
            },
            select: function (e, i) {
                $("#<%=hfCustomerId.ClientID %>").val(i.item.val);


            },
            minLength: 1
        });
    }


    );

   $('#cmdObtenerCoordenadas').click(function (e) {
            e.preventDefault(); // Usamos esta línea para cancelar el postback que el botón crea
            var parametros = {
                posicion: $('#txtLongitud').val()
            };

            // Ahora hacemos la llamada tipo AJAX utilizando jQuery
            $.ajax({
                type: 'POST',                               // tipo de llamada (POST, GET)
                url: '~/Mantenimientos/MantenimientoDeComercios.aspx',                // el URL del método que vamos a llamar
                data: JSON.stringify(parametros),           // los parámetros en formato JSON
                contentType: "application/json; charset=utf-8",
                dataType: "json",                           // tipo de datos enviados al servidor
                /*success: function () {                      // función que se va a ejecutar si el pedido resulta exitoso
                 /*   $('#lblMensaje').text('La información ha sido guardada exitosamente.');
                },
                error: function (req, stat, err) {          // función que se va a ejecutar si el pedido falla
                  /*  var error = eval("(" + req.responseText + ")");
                    $('#lblMensaje').text(error.Message);
                }*/
            });
        });


        function ObtenerPosicion() {
            var options = {
                enableHighAccuracy: true,
                timeout: 45000
            };

            navigator.geolocation.getCurrentPosition(GetPosition, funcionError, options);


            function GetPosition(posicion) {
                var latitudYLongitud = posicion.coords.latitude + ";" + posicion.coords.longitude;
                $("#txtLongitud").val(latitudYLongitud);
            }
            function funcionError(error) {
                alert(error.message);
            }
        }
       

</script>
<title></title>
<style type="text/css">

#map-canvas {
max-width: none;
height:110px;
width:90%;
}
#cmdObtenerCoordenadas {
width: 61px;
}
/*NUEVO*/


html,body{
  	height:100%;
}
body{
       /* background-image: url(Imagenes/fondo.jpg);*/
    background-repeat:no-repeat;
  	padding-top:50px; /*padding for navbar*/
    width:100%;
}
#main, #main>.row {
	height:100%;
}
#main>.row {
    overflow-y:scroll;
}
#left {
	height:100%;
}
.filter-box { 
  height: 15px; 
  width: 15px;  
  display: inline-block;
  *border-right-width: 2px;
  *border-bottom-width: 2px;
  -webkit-border-radius: 5px;
     -moz-border-radius: 5px;
          border-radius: 5px;
  -webkit-background-clip: padding-box;
     -moz-background-clip: padding;
          background-clip: padding-box; 
}

.filter-yellow { background-color: #FBF358; }
.filter-green { background-color: #00E13C; }
.filter-blue { background-color: #5781FC; }
.filter-purple { background-color: #7C54FB; }
.filter-red { background-color: #FB6353; }

canvas {-ms-touch-action: double-tap-zoom;}

hr{border: 0; height: 12px; box-shadow: inset 0 12px 12px -12px blue;}



/* customize nav style */
.navbar-custom {
    background-color: #4b4b4b;
	font-weight:700;
    text-transform:uppercase;
    border-width:0;
}
.navbar-custom  .navbar-nav>li>a {
	color: #ddd;
}
.navbar-custom  .navbar-nav li>a:hover, .navbar-nav li .open, .navbar-custom .navbar-nav .active a  {
	background-color: #7e7e7e;
}
.navbar-custom .dropdown-menu{
	right:0;
}
.navbar-custom .navbar-nav>.dropdown>a .caret {
	border-top-color: #999;
	border-bottom-color: #999;
}

.navbar-collapse.in { /*3.0.2 bug workaround*/
    overflow-y: visible;
}

.navbar-toggle {
	outline:0;
}
    </style>
</head>
<body  onload="initialize();">

 <header class="masthead">
    <!-- Static navbar -->
    <nav class="navbar navbar-custom navbar-fixed-top" id="nav">
      <div class="container">
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
                <li ><a href="<%= Page.ResolveUrl("~/PaginaPrincipalBT.aspx") %>">Principal</a></li>
                <li><a href="<%= Page.ResolveUrl("~/BusquedaComerciosGeoreferenciado.aspx") %>">Posición</a></li>
                <li><a href="<%= Page.ResolveUrl("~/BusquedaComercios.aspx") %>">Busqueda ampliada</a></li>
                <li><a href="<%= Page.ResolveUrl("~/BusquedaComerciosCercanos.aspx") %>">Cercanos</a></li>
                <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Gestiones <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                      <li class="active"><a href="<%= Page.ResolveUrl("~/Mantenimientos/MantenimientoDeComercios.aspx") %>">Gestión Comercio</a></li>
                      <li><a href="#">Gestion Usuario final</a></li>
                    </ul>
                </li>
          </ul> 
          <ul class="nav navbar-nav navbar-right">
            <li><a href="<%= Page.ResolveUrl("~/Sesion.aspx") %>">Inicio Sesión</a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>
</header>
        
<div class="container">
        
        
        
        
        
        
    <form id="form1" runat="server">         
        <div>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <asp:Label ID="Label1" runat="server" Text="Gestión Comercio" Font-Names="Verdana" Font-Size="X-Large" Font-Underline="True"></asp:Label>
        
&nbsp;&nbsp;
        
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<table border="0" cellpadding="5" style="height: 30px; margin-bottom: 0px; width: 100%;">
<tr>
<td class="auto-style30"><asp:Label ID="Label2" runat="server" Text="Nombre:"></asp:Label>
&nbsp;<asp:TextBox ID="txtNombre" runat="server" Width="197px"></asp:TextBox>
</td>
<td class="auto-style27"> <asp:Label ID="Label3" runat="server" Text="R.U.T:"></asp:Label>
&nbsp;&nbsp;
<asp:TextBox ID="txtRut" runat="server" Width="218px"></asp:TextBox>
    <asp:TextBox ID="txtId" runat="server" Width="16px" Visible="False"></asp:TextBox>
    </td>
<td class="auto-style16"><asp:Label ID="Label4" runat="server" Text="Dirección:"></asp:Label>
        <asp:TextBox ID="txtDireccion" runat="server" Width="224px"></asp:TextBox>
    </td>
</tr>
<tr>
<td class="auto-style30">
        <asp:Label ID="Label5" runat="server" Text="Teléfono:"></asp:Label>
&nbsp;<asp:TextBox ID="txtTelefono" runat="server" Width="195px"></asp:TextBox>
</td>
<td class="auto-style27"> 
        <asp:Label ID="Label6" runat="server" Text="Web:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp; <asp:TextBox ID="txtWeb" runat="server" Width="215px"></asp:TextBox>
    </td>
<td class="auto-style16">
    <asp:Label ID="Label11" runat="server" Text="Barrio:"></asp:Label>
    <asp:DropDownList ID="cmbBarrio" runat="server" Height="20px" Width="157px">
        </asp:DropDownList>
        <asp:Image ID="Image1" runat="server" Height="16px" Width="27px" />
    </td>
</tr>
<tr>
<td class="auto-style39">
    <asp:Label ID="Label9" runat="server" Text="Email:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="txtEmail" runat="server" Width="195px"></asp:TextBox>
</td>
<td class="auto-style40"> 
    <asp:Label ID="Label7" runat="server" Text="Coords:"></asp:Label>
&nbsp;<asp:TextBox id="txtLongitud"  runat="server" Width="153px"></asp:TextBox>
        <input type="button" id="cmdObtenerCoordenadas" value="Obtener" onclick="ObtenerPosicion()"/><br />
         <div id="map-canvas"></div> 
</td>
<td class="auto-style41">
    <asp:Label ID="Label8" runat="server" Text="Logo:"></asp:Label>
        <asp:FileUpload ID="FileUpload" runat="server" Width="255px" />
    </td>
</tr>
<tr>
<td class="auto-style36">
  
        <asp:Label ID="Label15" runat="server" Text="Tags:"></asp:Label>
        <asp:TextBox ID="txtAgregarTag" runat="server" Width="128px"></asp:TextBox>
        <asp:Button ID="cmdAgregarTag" runat="server" Text="Agregar" OnClick="cmdAgregarTag_Click" />
    <br />
        <asp:ListBox ID="LstTags" runat="server" Width="255px"></asp:ListBox>
        <asp:Label ID="lblTags" runat="server" ForeColor="Red"></asp:Label>
</td>
<td class="auto-style37"> 
        <asp:Label ID="Label10" runat="server" Text="Anuncio:"></asp:Label>
        <asp:TextBox ID="txtAnuncio" runat="server" Height="68px" Width="267px"></asp:TextBox>
    </td>
<td class="auto-style38">
        <asp:Label ID="Label12" runat="server" Text="Usuario:"></asp:Label>
        &nbsp;&nbsp;&nbsp; <asp:TextBox ID="txtNombreUsuario" runat="server" Width="215px"></asp:TextBox>
        <br />
        <asp:Label ID="Label13" runat="server" Text="Password:"></asp:Label>
        &nbsp;<asp:TextBox ID="txtPassword" runat="server" Width="213px" ></asp:TextBox>
    </td>
</tr>
<tr>
<td class="auto-style36">

            <asp:Label ID="Label14" runat="server" Text="Sucursales:"></asp:Label>
    <asp:TextBox ID="txtBuscarSucursales" runat="server" Width="148px"></asp:TextBox>
        <asp:Button ID="cmdBuscarSucursales" runat="server" Text="Añadir" OnClick="cmdBuscarSucursales_Click" Width="67px" />
        <br />
        <asp:HiddenField ID="hfCustomerId" runat="server"/>
</td>
<td class="auto-style37"> 
        <asp:Label ID="Label18" runat="server" Text="Rubros:"></asp:Label>
        <asp:DropDownList ID="cmbRubros" runat="server" style="margin-left: 0px" Width="175px" >
        </asp:DropDownList>
        <asp:Button ID="cmdAñadirRubro" runat="server" Text="Añadir" OnClick="cmdAñadirRubro_Click" />
    </td>
<td class="auto-style38">
        <asp:Label ID="Label16" runat="server" Text="Redes:"></asp:Label>
        <asp:DropDownList ID="cmbRedSocial" runat="server">
        </asp:DropDownList>
    <asp:TextBox ID="txtAgregarRedSocial" runat="server" Width="134px"></asp:TextBox>
        <asp:Button ID="cmdAgregarRedSocial" runat="server" Text="+" OnClick="cmdAgregarRedSocial_Click" Height="25px" Width="24px" />
    </td>
</tr>
<tr>
<td class="auto-style32">
               <asp:GridView ID="GridSucursales" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal" Height="16px" Width="264px">
            <Columns>
                <asp:HyperLinkField AccessibleHeaderText="ComercioId" DataNavigateUrlFields="ComercioId" DataNavigateUrlFormatString="MantenimientoDeComercios.aspx?ComercioId={0}" DataTextField="ComercioId" HeaderText="ComercioId" Visible="False" />
                <asp:BoundField AccessibleHeaderText="ComercioNombre" DataField="ComercioNombre" HeaderText="Comercio" />
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#333333" />
            <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="White" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F7F7F7" />
            <SortedAscendingHeaderStyle BackColor="#487575" />
            <SortedDescendingCellStyle BackColor="#E5E5E5" />
            <SortedDescendingHeaderStyle BackColor="#275353" />
        </asp:GridView>

   
    <br />
    <br />
</td>
<td class="auto-style29"> 
        <asp:GridView ID="GridRubros" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal" Height="16px" Width="264px">
            <Columns>
                <asp:BoundField AccessibleHeaderText="RubId" HeaderText="RubId" Visible="False" DataField="RubId" />
                <asp:HyperLinkField AccessibleHeaderText="RubNombre" DataNavigateUrlFields="RubId" DataNavigateUrlFormatString="MantenimientoDeComercios.aspx?RubId={0}" DataTextField="RubNombre" HeaderText="Rubro" />
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#333333" />
            <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="White" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F7F7F7" />
            <SortedAscendingHeaderStyle BackColor="#487575" />
            <SortedDescendingCellStyle BackColor="#E5E5E5" />
            <SortedDescendingHeaderStyle BackColor="#275353" />
        </asp:GridView>
        <br />
    </td>
<td class="auto-style2"><asp:GridView ID="GridRedesSociales" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal" Height="16px" Width="286px">
            <Columns>
                <asp:BoundField AccessibleHeaderText="RedId" HeaderText="RedId" Visible="False" DataField="RedId" />
                <asp:HyperLinkField AccessibleHeaderText="RedNombre" DataNavigateUrlFields="RedId" DataNavigateUrlFormatString="MantenimientoDeComercios.aspx?RedId={0}" DataTextField="RedNombre" HeaderText="Red Social" />
                <asp:BoundField AccessibleHeaderText="RedDescripcion" DataField="RedDescripcion" HeaderText="Dirección" />
            </Columns>
            <FooterStyle BackColor="White" ForeColor="#333333" />
            <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="White" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F7F7F7" />
            <SortedAscendingHeaderStyle BackColor="#487575" />
            <SortedDescendingCellStyle BackColor="#E5E5E5" />
            <SortedDescendingHeaderStyle BackColor="#275353" />
        </asp:GridView>
    <asp:Label ID="lblRedSocial" runat="server" ForeColor="Red"></asp:Label>
    <br />
    </td>
</tr>
</table>
<asp:Button ID="cmdAceptar" runat="server" OnClick="cmdAceptar_Click" Text="Aceptar" />
<asp:Button ID="cmCancelar" runat="server" Text="Cancelar" />
        <asp:Label ID="lblResultado" runat="server" Font-Bold="False" Font-Names="Verdana" Font-Size="Medium" ForeColor="Red"></asp:Label>
    
    </div>
        <p>
        <asp:Label ID="Label17" runat="server" Text="Imagenes:"></asp:Label>
        </p>
        <p>
    <asp:Image ID="img1" runat="server" Height="58px" Width="91px" />
    <asp:Image ID="img2" runat="server" Height="58px" Width="91px" />
    <asp:Image ID="img3" runat="server" Height="58px" Width="91px" />
        </p>
    </form>
    </div>
    
</body>

   
</html>

